﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MDX_Studio_v2
{
	public class QueryEditorInfo
	{
		private int _id;
		private string _filePath;
		private string _name;
		private bool _unsavedChanges;

		/// <summary>
		/// Constructor
		/// </summary>
		public QueryEditorInfo()
		{
			_id = -1;
			_filePath = null;
			_name = null;
			_unsavedChanges = true;
		}

		/// <summary>
		/// PArameterized constructor; 'Name' is inferred
		/// </summary>
		/// <param name="id"></param>
		/// <param name="filepath"></param>
		public QueryEditorInfo(int id, string filepath)
		{
			_id = id;
			_filePath = filepath;
			if (filepath != null) _name = filepath.Split('\\')[filepath.Split('\\').Length - 1];
			else _name = null;
			_unsavedChanges = true;
		}

		// Memeber Accessors
		public int ID { get { return _id; } set { _id = value; } }
		public string FilePath { get { return _filePath; } set { _filePath = value; } }
		public string Name { get { return _name; } set { _name = value; } }
		public bool UnsavedChanges { get { return _unsavedChanges; } set { _unsavedChanges = value; } }

		public string Title
		{
			get
			{
				if (this.Name == null) return "Query " + this.ID + (this.UnsavedChanges ? "*" : "");
				return this.Name;
			}
			set { }
		}
	}
}
